<!--{template /module/admin/view/head}-->
<div id="left_layout">
	<div id="main_content" class="container-fluid {echo in_array($_var['gp_ref'], array('desktop', 'audit', 'recycle')) ? '' : '';}">
		<div class="row-fluid">
			<form method="post" action="{$ADMIN_SCRIPT}/cms/{$dispatches[control]}/_update&id={$_var[gp_id]}&cid={$_var[gp_cid]}&page={$_var[page]}&psize={$_var[psize]}{$search[querystring]}" onsubmit="javascript:return check_form(this);">
			<input type="hidden" name="formsubmit" value="yes"/>
			<input type="hidden" name="hdnCategoryID" id="hdn_categoryid" value="{$article[CATEGORYID]}"/>
			<input type="hidden" name="hdnModule" id="hdn_module" value="{$article[MODULE]}"/>
			<div class="well widget">
				<div class="widget-header">
					<p class="text">* {lang admin.validate.require}</p>
				</div>
				<div class="widget-content">
				<fieldset>
					<table width="100%" border="0">
	            		<tr>
			            	<td>
			            		<label>{lang cms.article_edit.view.title.label} *</label>
								<input type="text" class="input-xxlarge" name="txtTitle" placeholder="{lang cms.article_edit.view.title.placeholder}" maxlength="50" value="{$article[TITLE]}" /> 
								<span class="help-inline">{lang cms.article_edit.view.title.tips}</span>
								
								<label>{lang cms.article_edit.view.pubdate.label}/{lang cms.article_edit.view.expried.label}</label> 
								<input type="text" class="input-medium input-time" name="txtPubdate" value="{$article[PUBDATE]}" /> / 
								<input type="text" class="input-medium input-date" name="txtExpried" value="{$article[EXPRIED]}"/> 
								<span class="help-inline">{lang cms.article_edit.view.pubdate.tips}</span>
								
								<label>{lang cms.article_edit.view.subtitle.label}</label>
								<input type="text" name="txtSubTitle1" maxlength="50" class="input-large" value="{$article[SUBTITLE1]}"/>
								<input type="text" name="txtSubTitle2" maxlength="50" class="input-large" value="{$article[SUBTITLE2]}"/>
								<input type="text" name="txtSubTitle3" maxlength="50" class="input-large" value="{$article[SUBTITLE3]}"/> 
								<span class="help-inline">{lang cms.article_edit.view.subtitle.tips}</span>
								
								<label>{lang cms.article_edit.view.category.label}</label>
								<div id="tree_list"></div>
								
								<div id="div_address" style="display:none;">
									<label>{lang cms.article_edit.view.address.label}</label>
									<input type="text" name="txtAddress" maxlength="50" class="input-xxlarge" value="{$article[ADDRESS]}"/>
									<span class="help-inline">{lang cms.article_edit.view.address.tips}</span>
								</div>
								
								<div id="div_author" style="display:none;">
									<label>{lang cms.article_edit.view.author.label}</label>
									<input type="text" name="txtAuthor" maxlength="50" class="input-xxlarge" value="{$article[AUTHOR]}"/>
									<span class="help-inline">{lang cms.article_edit.view.author.tips}</span>
								</div>
								
								<div id="div_keywords" style="display:none;">
									<label>{lang cms.article_edit.view.keywords.label}</label>
									<input type="text" name="txtKeywords" maxlength="50" class="input-xxlarge" value="{$article[KEYWORDS]}"/>
									<span class="help-inline">{lang cms.article_edit.view.keywords.tips}</span>
								</div>
								
								<div id="div_link" style="display:none;">
									<label>{lang cms.article_edit.view.link.label}</label>
									<input type="text" name="txtLink" maxlength="200" class="input-xxlarge" value="{$article[LINK]}"/>
									<span class="help-inline">{lang cms.article_edit.view.link.tips}</span>
								</div>
			            	</td>
			            	<td width="120" valign="bottom" align="right">
			            		<button type="button" state="0" class="btn btn-small btn-show" onclick="javascript:void(0);">{lang cms.article_edit.view.button.show}</button>
			            	</td>
			            </tr>
			        </table>
					
					<div class="show-more" style="display:none;">
						<hr/>
						<button type="button" name="btnMobule" class="btn btn-small btn-module"><i class="micon-wrench"></i> {lang cms.article_edit.view.module.button}</button>
						<span class="help-inline">{lang cms.article_edit.view.module.tips}</span>
						<p class="f12 muted module">
							<i class="micon-clipboard-2"></i> <span class="tips">{$article[MODULE_TIPS]}</span>
						</p>
						<hr/>
					</div>
					
					<div id="div_summary" style="display:none;">
						<label class="text">{lang cms.article_edit.view.summary.label}</label>
						<div class="pick">
							<textarea class="span8" rows="4" name="txtSummary">{$article[SUMMARY]}</textarea>
							<span class="help-inline">{lang cms.article_edit.view.summary.tips}</span>
						</div>
					</div>
					
					<div id="div_content">
						<label>
							<span class="text">{lang cms.article_edit.view.content.label}</span>
						</label>
						
				        <div class="content" style="display:{echo $article['TYPE'] == 2 ? 'none' : '';};">
							<textarea name="txtContent" id="txt_content" rows="16" class="span8" style="width:100%;">{$article[CONTENT]}</textarea>
							<span class="help-inline">{lang cms.article_edit.view.content.tips}</span>
						</div>
						
						<div class="file" style="display:{echo $article['TYPE'] == 2 ? '' : 'none';};">
							<div id="divFileUploadButton" class="upload-button"><span id="spnFileButtonPlaceholder"></span></div>
							<div id="divFileProgressContainer" class="upload-progress"></div>
							<br/>
							<table class="table" style="width:auto;">
								<tr>
								<td>
									<!--{if is_array($article['FILE'])}-->
									<input type="hidden" name="hdnFilePath" value="{$article[FILE][4]}"/>
									<p class="text-info path"><strong><a href="{$article[FILE][0]}" target="_blank">{$article[FILE][1]}</a></strong></p>
									<!--{else}-->
									<input type="hidden" name="hdnFilePath" value=""/>
									<p class="text-info path">{lang cms.article_edit.view.content.file.empty}</p>
									<!--{/if}-->
								</td>
								<td>
									<button type="button" name="btnMobule" class="btn btn-mini btn-file-delete" style="display:{echo is_array($article['FILE']) ? '' : 'none';};">删除</button>
								</td>
								</tr>
							</table>
						</div>
					</div>
					
					<!--{if count($subjects) > 0}-->
					<hr/>
					<label>{lang cms.article_edit.view.subject.label}</label>
					<select name="sltSubjectId">
						<option value="0">{lang cms.article_edit.view.subject.select}</option>
						<!--{loop $subjects $key $item}-->
						<option value="{$item[SUBJECTID]}" {if $item['SUBJECTID'] == $article['SUBJECTID']}selected="selected"{/if}>{$item[TITLE]}</option>
						<!--{/loop}-->
					</select>
					<span class="help-inline">{lang cms.article_edit.view.subject.tips}</span>
					<!--{/if}-->
					
					<table>
						<tr>
							<td>
								<label>{lang cms.article_edit.view.iscommend.label}</label>
								<select name="eleIsCommend">
							        <option value="0">{lang cms.article_edit.view.iscommend.option.0}</option>
							        <option value="10" {if $article['ISCOMMEND'] == 10}selected="selected"{/if}>{lang cms.article_edit.view.iscommend.option.10}</option>
							        <option value="9" {if $article['ISCOMMEND'] == 9}selected="selected"{/if}>{lang cms.article_edit.view.iscommend.option.9}</option>
							        <option value="8" {if $article['ISCOMMEND'] == 8}selected="selected"{/if}>{lang cms.article_edit.view.iscommend.option.8}</option>
							        <option value="7" {if $article['ISCOMMEND'] == 7}selected="selected"{/if}>{lang cms.article_edit.view.iscommend.option.7}</option>
							        <option value="6" {if $article['ISCOMMEND'] == 6}selected="selected"{/if}>{lang cms.article_edit.view.iscommend.option.6}</option>
							        <option value="5" {if $article['ISCOMMEND'] == 5}selected="selected"{/if}>{lang cms.article_edit.view.iscommend.option.5}</option>
							        <option value="4" {if $article['ISCOMMEND'] == 4}selected="selected"{/if}>{lang cms.article_edit.view.iscommend.option.4}</option>
							        <option value="3" {if $article['ISCOMMEND'] == 3}selected="selected"{/if}>{lang cms.article_edit.view.iscommend.option.3}</option>
							        <option value="2" {if $article['ISCOMMEND'] == 2}selected="selected"{/if}>{lang cms.article_edit.view.iscommend.option.2}</option>
							        <option value="1" {if $article['ISCOMMEND'] == 1}selected="selected"{/if}>{lang cms.article_edit.view.iscommend.option.1}</option>
						        </select>
								<span class="help-inline">{lang cms.article_edit.view.iscommend.tips}</span>
							</td>
							<td width="50">&nbsp;</td>
							<td>
								<label>{lang cms.article_edit.view.istop.label}</label>
								<label class="checkbox inline">
									<input type="radio" class="fancy" name="rdoIsTop" value="1" {if $article['ISTOP'] == 1}checked="checked"{/if}/>{lang cms.article_edit.view.istop.yes.label}
								</label>
								<label class="checkbox inline">
									<input type="radio" class="fancy" name="rdoIsTop" value="0" {if $article['ISTOP'] == 0}checked="checked"{/if}/>{lang cms.article_edit.view.istop.no.label}
								</label>
							</td>
						</tr>
					</table>
				</fieldset>
				
				<div id="div_files" style="display:none;">
					<h5>{lang admin.validate.swfupload}({lang admin.validate.swfupload.limit}{$table[FILENUM]}{lang admin.validate.swfupload.unit})</h5>
					<div class="upload">
						<hr/>
						<div id="divImageUploadButton" class="upload-button"><span id="spnImageButtonPlaceholder"></span></div>
						<div id="divImageProgressContainer" class="upload-progress"></div>
		            	<div id="divThumbnails">
		            	<table class="table" style="width:auto;">
		            		<thead>
		            			<tr>
			            			<th width="60">{lang admin.validate.swfupload.th.pic}</th>
			            			<th>{lang admin.validate.swfupload.th.name}</th>
			            			<th width="60">{lang admin.validate.swfupload.th.no}</th>
			            			<th width="80">{lang admin.validate.swfupload.th.delete}</th>
		            			</tr>
		            		</thead>
		            		<tbody id="tbl_body_column">
		            		<!--{loop $article_files $key $image}-->
		            		<tr>
				            	<td>
				            		<input type="hidden" name="hdnImagePath[]" value="{$image[4]}" />
				            		<a href="{$image[3]}" target="_blank"><img class="image" style="width:60px;" src="{$image[0]}" border="0" /></a>
				            	</td>
				            	<td>
				            		<span class="imageTitle">{$image[1]}<!--{if $image[5]}--><br/>[{$image[5]}px * {$image[6]}px]<!--{/if}--></span>
				            	</td>
				            	<td>
					            	<input type="text" name="txtImageDisplayOrder[]" value="{echo $key + 1;}" class="input-mini" />
				            	</td>
				            	<td>
				            		<a class="btn btn-mini btn-delete" href="javascript:void(null);" onclick="removeImage(this)">{lang admin.operation.delete}</a>
				            	</td>
				            </tr>
		            		<!--{/loop}-->
		            		<tr id="tbl_no_record"{if count($article_files) > 0} style="display:none;"{/if}>
		            			<td colspan="4">{lang admin.validate.swfupload.empty}</td>
		            		</tr>
			            	<tr style="display:none;">
				            	<td>
				            		<input type="hidden" name="hdnImagePath[]" value="" />
				            		<img class="image" style="width:60px;" src="" />
				            	</td>
				            	<td>
					            	<span class="imageTitle"></span>
				            	</td>
				            	<td>
					            	<input type="text" name="txtImageDisplayOrder[]" value="" class="input-mini" />
				            	</td>
				            	<td>
				            		<a class="btn btn-mini btn-delete" href="javascript:void(null);" onclick="removeImage(this)">{lang admin.operation.delete}</a>
				            	</td>
				            </tr>
				            </tbody>
				        </table>
				        </div>
			        </div>
		        </div>
		        
				<fieldset>
					<hr/>
					<button type="submit" class="btn btn-small btn-primary" {$dispatches[operations][edit]}>{lang admin.operation.submit}</button>
					<button type="reset" class="btn btn-small">{lang admin.operation.reset}</button>
					<button type="button" class="btn btn-small" onclick="javascript:location.href='{$ADMIN_SCRIPT}/cms/{$dispatches[control]}/_list&cid={$_var[gp_cid]}&page={$_var[page]}&psize={$_var[psize]}{$search[querystring]}';">{lang admin.operation.go.back}</button>
				</fieldset>
				</div>
			</div>
			</form>
		</div>
	</div>
</div>

<script type="text/javascript" src="editor/kindeditor.js"></script>
<script type="text/javascript" src="editor/lang/zh_CN.js"></script>

<script type="text/javascript" src="static/plugins/swfupload.js"></script>
<script type="text/javascript" src="static/plugins/swfupload_handlers.js"></script>
<script type="text/javascript" src="static/plugins/swfupload_images.js"></script>

<script>
var categoryPath = '{$category[PATH]}';
var categoryType = {echo $category['COLUMNS']['CONTENT']['type'] + 0;};

var hdnModule = null;

var swf_file, swf_img;

swfupload_params.limit = {echo $table[FILENUM];};
swfupload_params.uploaded = {echo count($article_files);};

var params_file = {limit:1, uploaded:0};

var kindEditor = null;

function addFile(src){
	var tmp = src.split('|');
	$('#div_content .file input').val(src);
	$('#div_content .file .path').html('<strong><a href="' + formatFilePath(src) + '" target="_blank">' + tmp[1] + '</a></strong>');
	$('#div_content .file table button').show();
}

function fileQueueError(file, errorCode, message) {
	try {
		var imageName = "error.gif";
		var errorName = "";
		
		if (errorCode === SWFUpload.QUEUE_ERROR.QUEUE_LIMIT_EXCEEDED) {
			errorName = swfupload.lang.limit;
		}

		if (errorName !== "") {
			$.dialog({message:errorName});
			return;
		}
		
		$.dialog({message:message});
	} catch (ex) {}
}

function fileDialogComplete(numFilesSelected, numFilesQueued) {
	try {
		if (numFilesQueued > 0) {
			this.setPostParams(params_file);
			this.startUpload();
		}
	} catch (ex) {}
}

function imageDialogComplete(numFilesSelected, numFilesQueued) {
	try {
		if (numFilesQueued > 0) {
			this.setPostParams(swfupload_params);
			this.startUpload();
		}
	} catch (ex) {}
}

function fileUploadSuccess(file, serverData) {
	try {
		var progress = new FileProgress(file,  this.customSettings.upload_target);
		
		if (serverData.substring(0, 7) === "FILEID:") {
			addFile(serverData.substring(7));
			
			progress.setStatus(swfupload.lang.end);
			progress.toggleCancel(false);
		} else {
			progress.setStatus(swfupload.lang.error);
			progress.toggleCancel(false);
			$.dialog({message:serverData});
		}
	} catch (ex) {}
}

function fileUploadComplete(){
	try {
		if (this.getStats().files_queued > 0) {
			this.setPostParams(params_file);
			this.startUpload();
		} else {
			var progress = new FileProgress(file,  this.customSettings.upload_target);
			progress.setComplete();
			progress.setStatus(swfupload.lang.over);
			progress.toggleCancel(false);
		}
	} catch (ex) {}
}

function get_select_list(id, slt){
	var index = slt == null ? -1 : slt.selectedIndex;
	var pid = index != -1  ? slt.options[index].value : '0';
	var node = $('#' + id).get(0);
	
	var hdn = $('#hdn_categoryid').get(0);
	hdn.value = pid;
	
	var idarray = pid.split(',');
	pid = idarray[0];
	
	if(pid == '-1'){
		node.innerHTML = ''; 
		return;
	}
	
	$.getJSON('{$ADMIN_SCRIPT}/cms/{$dispatches[control]}/_category&rnd=' + Math.random(), {parentid:pid}, function(data){
		$('.help-inline .btn').remove();
		
		KindEditor.remove('#txt_content');
		
		if(data.DATA.length == 0){
			if(data.CATEGORY instanceof Array || data.CATEGORY.COLUMNS instanceof Array){
				$('#div_address label').html('{lang cms.article_edit.view.address.label}');
				$('#div_author label').html('{lang cms.article_edit.view.author.label}');
				$('#div_keywords label').html('{lang cms.article_edit.view.keywords.label}');
				$('#div_link label').html('{lang cms.article_edit.view.link.label}');
				$('#div_summary .text').html('{lang cms.article_edit.view.summary.label}');
				$('#div_content .text').html('{lang cms.article_edit.view.content.label}');
				
				$('#div_address').hide();
				$('#div_author').hide();
				$('#div_keywords').hide();
				$('#div_link').hide();
				
				$('#div_summary').hide();
				$('#div_files').hide();
				
				$('#div_content .content').show();
				$('#div_content .file').hide();
				
				kindEditor = KindEditor.create('#txt_content', kind_editor_onfig);
			}else{
				if(typeof(data.CATEGORY.COLUMNS.SUMMARY) != 'undefined'){
					$('#div_summary .text').html(data.CATEGORY.COLUMNS.SUMMARY.text ? data.CATEGORY.COLUMNS.SUMMARY.text : '{lang cms.article_edit.view.summary.label}');
					
					if(data.CATEGORY.COLUMNS.SUMMARY.show == 1) $('#div_summary').show();
					else $('#div_summary').hide();
				}
				
				if(typeof(data.CATEGORY.COLUMNS.CONTENT) != 'undefined'){
					categoryType = data.CATEGORY.COLUMNS.CONTENT.type;
					
					$('#div_content .text').html(data.CATEGORY.COLUMNS.CONTENT.text ? data.CATEGORY.COLUMNS.CONTENT.text : '{lang cms.article_edit.view.content.label}');
					
					if(categoryType == 1){
						//显示文本域
						$('#div_content .content').show();
						$('#div_content .file').hide();
					}else if(categoryType == 2){
						//显示文件上传
						$('#div_content .content').hide();
						$('#div_content .file').show();
					}else{
						//显示HTML编辑器
						$('#div_content .content').show();
						$('#div_content .file').hide();
						
						kindEditor = KindEditor.create('#txt_content', kind_editor_onfig);
					}
				}else{
					categoryType = 0;
					
					$('#div_content .text').html('{lang cms.article_edit.view.content.label}');
					
					//显示HTML编辑器
					$('#div_content .content').show();
					$('#div_content .file').hide();
					
					kindEditor = KindEditor.create('#txt_content', kind_editor_onfig);
				}
				
				if(typeof(data.CATEGORY.COLUMNS.ADDRESS) != 'undefined'){
					$('#div_address label').html(data.CATEGORY.COLUMNS.ADDRESS.text ? data.CATEGORY.COLUMNS.ADDRESS.text : '{lang cms.article_edit.view.address.label}');
					
					if(data.CATEGORY.COLUMNS.ADDRESS.show == 1) $('#div_address').show();
					else $('#div_address').hide();
				}
				
				if(typeof(data.CATEGORY.COLUMNS.AUTHOR) != 'undefined'){
					$('#div_author label').html(data.CATEGORY.COLUMNS.AUTHOR.text ? data.CATEGORY.COLUMNS.AUTHOR.text : '{lang cms.article_edit.view.author.label}');
					
					if(data.CATEGORY.COLUMNS.AUTHOR.show == 1) $('#div_author').show();
					else $('#div_author').hide();
				}
				
				if(typeof(data.CATEGORY.COLUMNS.KEYWORDS) != 'undefined'){
					if(data.CATEGORY.COLUMNS.KEYWORDS.text){
						$('#div_keywords label').html(data.CATEGORY.COLUMNS.KEYWORDS.text);
						$('#div_keywords .help-inline').html('{lang cms.article_edit.view.keywords.tips.new}');
					}else{
						$('#div_keywords label').html('{lang cms.article_edit.view.keywords.label}');
						$('#div_keywords .help-inline').html('{lang cms.article_edit.view.keywords.tips}');
					}
					
					if(data.CATEGORY.COLUMNS.KEYWORDS.show == 1) $('#div_keywords').show();
					else $('#div_keywords').hide();
				}
				
				if(typeof(data.CATEGORY.COLUMNS.LINK) != 'undefined'){
					$('#div_link label').html(data.CATEGORY.COLUMNS.LINK.text ? data.CATEGORY.COLUMNS.LINK.text : '{lang cms.article_edit.view.link.label}');
					
					if(data.CATEGORY.COLUMNS.LINK.show == 1) $('#div_link').show();
					else $('#div_link').hide();
				}
			}
			
			if(typeof(data.CATEGORY.FILES) != 'undefined' && data.CATEGORY.FILES){
				$('#div_files h5').html(data.CATEGORY.FILES.text);
				$('#div_files .upload').show();
				
				if(data.CATEGORY.FILES.show == 1) $('#div_files').show();
				else $('#div_files').hide();
			}else{
				$('#div_files h5').html('{lang admin.validate.swfupload}({lang admin.validate.swfupload.limit}{$table[FILENUM]}{lang admin.validate.swfupload.unit})');
			}
			
			node.innerHTML = ''; 
			return;
		}
		
		node.innerHTML = '';
		node.innerHTML += "<select name=\"sltCategory" + pid + "\" id=\"slt_category_" + pid + "\" onchange=\"get_select_list('tree_list_" + pid + "',this)\"></select>&nbsp;";
		node.innerHTML += "<span id=\"tree_list_" + pid + "\"></span>";
		
		var slt = $('#slt_category_' + pid).get(0);
		slt.options[0] = new Option('{lang cms.article_edit.view.category.option}', '-1');
		for(var i=0; i < data.DATA.length; i++){
			slt.options[i + 1] = new Option(data.DATA[i].CNAME, data.DATA[i].CATEGORYID + ',' + data.DATA[i].CHILDREN);
			if(categoryPath.indexOf(',' + data.DATA[i].CATEGORYID + ',') != -1){
				slt.options[i + 1].selected = 'selected';
				get_select_list('tree_list_' + pid, slt);
			}
		}
	});
}

function check_form(frm){
    if(frm.txtTitle.value.trim().length == 0){
    	$(frm.txtTitle).next('.help-inline').css('color', 'red');
    	frm.txtTitle.focus();
    	return false;
    }
    
    var arrCategory = frm.hdnCategoryID.value.trim().split(',');
    if(arrCategory.length < 1 || arrCategory[0] - 0 == 0){
    	$.dialog({message: '{lang cms.article_edit.view.validate.category}'});
    	return false;
    }
    
    if(arrCategory.length > 1 && arrCategory[1] > 0){
    	$.dialog({message: '{lang cms.article_edit.view.validate.children}'});
    	return false;
    }
    
    if(categoryType == 0){
	    if(kindEditor.isEmpty()){
	    	$.dialog({message: '{lang cms.article_edit.view.validate.content}'});
	    	kindEditor.focus();
	    	return false;
	    }
    }else if(categoryType == 1){
    	if(frm.txtContent.value.trim().length == 0){
	    	$.dialog({message: '{lang cms.article_edit.view.validate.content}'});
	    	frm.txtContent.focus();
	    	return false;
    	}
    }else if(categoryType == 2){
    	frm.txtContent.value = '';
    }
    
    frm.hdnCategoryID.value = arrCategory[0];
    
    return true;
}

function show_toggle(){
	var state = $('.btn-show').attr('state');
	if(state == '0'){
		$('.btn-show').html('{lang cms.article_edit.view.button.hide}').attr('state', '1');
	}else{
		$('.btn-show').html('{lang cms.article_edit.view.button.show}').attr('state', '0');
	}
	
	$('.show-more').toggle();
}

$(function(){
	$('.fancy').uniform();
	
	$('.input-date').datepicker({format:'yyyy-mm-dd'});
	$('.input-time').datetimepicker({format: 'yyyy-mm-dd hh:ii', autoclose:true, todayBtn:true});
	
	$('fieldset input,textarea').blur(function(){
		$(this).next('.help-inline').css('color', '#333');
	});
	
	$('.btn-show').click(function(){
		show_toggle();
	});
	
	$('.btn-module').click(function(){
		var module = hdnModule ? hdnModule.value : '';
		
		$.dialog({width:500, title:'{lang cms.article_edit.view.module.dialog.title}', submit:'{lang cms.article_edit.view.module.btn.submit}', href:'{$ADMIN_SCRIPT}/cms/{$dispatches[control]}/_module&module=' + module, callback:function(){
			$('#modal_dialog .module-extend .fancy').uniform();
			$('#modal_dialog .module-extend .input-time').datetimepicker({format: 'yyyy-mm-dd hh:ii', autoclose:true, todayBtn:true});
			$('#modal_dialog .modal-body').css({padding:'12px 12px 0 12px', background:'#f5f5f5'});
			
			if($('#modal_dialog .module-extend .position').length > 0){
				var tmparr = $('#modal_dialog .module-extend .position').val();
				tmparr = tmparr.split(',');
				$('#modal_dialog').css({width:tmparr[0] + 'px', marginLeft:tmparr[1] + 'px'});
			}
			
			$('#modal_dialog .module-list button').click(function(){
				$('#modal_dialog .module-list button').removeClass('btn-success');
				$(this).addClass('btn-success');
				
				$.get('{$ADMIN_SCRIPT}/cms/{$dispatches[control]}/_module&do=extend&rnd=' + Math.random(), {module:$(this).attr('data')}, function(data){
					$('#modal_dialog .module-extend').html(data);
					$('#modal_dialog .module-extend .fancy').uniform();
					$('#modal_dialog .module-extend .input-time').datetimepicker({format: 'yyyy-mm-dd hh:ii', autoclose:true, todayBtn:true});
					
					if($('#modal_dialog .module-extend .position').length > 0){
						var tmparr = $('#modal_dialog .module-extend .position').val();
						tmparr = tmparr.split(',');
						$('#modal_dialog').css({width:tmparr[0] + 'px', marginLeft:tmparr[1] + 'px'});
					}else{
						$('#modal_dialog').css({width:'500px', marginLeft:'-250px'});
					}
				});
			});
		}});
	});
	
	$('.btn-file-delete').click(function(){
		$('#div_content .file input').val('');
		$('#div_content .file .path').html('{lang cms.article_edit.view.content.file.empty}');
		$(this).hide();
	});
	
	hdnModule = $('#hdn_module').get(0);
 	get_select_list('tree_list', null);
 	
 	swf_file = new SWFUpload({
		upload_url: "{$ADMIN_SCRIPT}/cms/{$dispatches[control]}/_upload&type=file&_SALT={$_var[current][SALT]}",
		
		file_size_limit : "30MB", 
		file_types : "*.*",
		file_types_description : "Files",
		file_upload_limit : "0",
		
		file_queue_error_handler : fileQueueError,
		file_dialog_complete_handler : fileDialogComplete,
		upload_progress_handler : uploadProgress,
		upload_error_handler : uploadError,
		upload_success_handler : fileUploadSuccess,
		upload_complete_handler : fileUploadComplete,
		
		button_image_url : "static/images/swfupload/swfupload.png",
		button_placeholder_id : "spnFileButtonPlaceholder",
		button_width: 150,
		button_height: 18,
		button_text : '{lang admin.validate.swfupload.lang.button.file}({lang admin.validate.swfupload.lang.button.size.30m})',
		button_text_style : '',
		button_text_top_padding: 0,
		button_text_left_padding: 18,
		
		flash_url : "static/swfupload.swf", 
		custom_settings : {
			upload_target : "divFileProgressContainer"
		},
		debug: false
	});
	
	swf_image = new SWFUpload({
		upload_url: "{$ADMIN_SCRIPT}/cms/{$dispatches[control]}/_upload&type=image&_SALT={$_var[current][SALT]}",
		
		file_size_limit : "300KB", 
		file_types : "*.jpg;*.bmp;*.gif;*.png",
		file_types_description : "JPG Images",
		file_upload_limit : "0",
		
		file_queue_error_handler : fileQueueError,
		file_dialog_complete_handler : imageDialogComplete,
		upload_progress_handler : uploadProgress,
		upload_error_handler : uploadError,
		upload_success_handler : uploadSuccess,
		upload_complete_handler : uploadComplete,
		
		button_image_url : "static/images/swfupload/swfupload.png",
		button_placeholder_id : "spnImageButtonPlaceholder",
		button_width: 150,
		button_height: 18,
		button_text : '{lang admin.validate.swfupload.lang.button}({lang admin.validate.swfupload.lang.button.size.300})',
		button_text_style : '',
		button_text_top_padding: 0,
		button_text_left_padding: 18,
		
		flash_url : "static/swfupload.swf", 
		custom_settings : {
			upload_target : "divImageProgressContainer"
		},
		debug: false
	});
	
	{if $article['MODULE'] && $article['MODULE'] != 'empty'}
		$('.btn-show').html('{lang cms.article_edit.view.button.hide}').attr('state', '1');
		$('.show-more').show();
	{/if}
	
	{if $article['TYPE'] == 0}
	kindEditor = KindEditor.create('#txt_content', kind_editor_onfig);
	{/if}
});
</script>

<!--{template /module/admin/view/foot}-->